package com.ruoyi.common.enums;

import java.util.HashMap;
import java.util.Map;

public enum WeaponType {
    TYPE_32(32, "步枪", "2"),
    TYPE_95(95, "其他", "7"),
    TYPE_44(44, "微型冲锋枪", "3"),
    TYPE_52(52, "霰弹枪", "6"),
    TYPE_21(21, "手枪", "1"),
    TYPE_106(106, "印花", "9"),
    TYPE_1(1, "匕首", "0"),
    TYPE_57(57, "机枪", "8"),
    TYPE_60(60, "手套", "4"),
    TYPE_321(32, "狙击步枪", "5");

    private static final Map<String, WeaponType> typeIdMap = new HashMap<>();
    private final Integer typeId;
    private final String typeName;
    private final String code;

    static {
        for (WeaponType type : WeaponType.values()) {
            typeIdMap.put(type.getTypeName(), type);
        }
    }

    WeaponType(int typeId, String typeName, String code) {
        this.typeId = typeId;
        this.typeName = typeName;
        this.code = code;
    }

    public int getTypeId() {
        return typeId;
    }

    public String getTypeName() {
        return typeName;
    }

    public String getCode() {
        return code;
    }

    public static WeaponType getTypeName(String typeName) {
        return typeIdMap.get(typeName) == null ? WeaponType.TYPE_95 : typeIdMap.get(typeName);
    }
}

